<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="UTF-8">
    <title>Test</title>
</head>

<body>
<p id="content">这是html内容</p>
<input class="input" type="text" value="" id="inputText1" />
<input class="input" type="text" value="" id="inputText2" />
<div class="buttons">
    <button type="button" id="button1" onclick="callAndroid()">测试语音</button>
    <button type="button" id="button2" onclick="callAndroid1()">获取安卓数据</button>
    <button type="button" id="button3" onclick="callAndroid2()">设置音量</button>
    <button onclick="clickTestSpeek()" class="button">测试语音</button>
    <button onclick="updateApk()" class="button">更新</button>
    <button onclick="setOffPower()" class="button">定时开关机</button>
</div>
</body>
<script>
    function setOffPower(){
        AndroidBrowser.setPowerOnOff();
    }

    function callAndroid() {
        //alert("callAndroid");
        // 由于对象映射，所以调用Android对象等于调用Android映射的对象
        AndroidBrowser.setAndroidVolume(2)
        AndroidBrowser.setSpeechRate(3);
        AndroidBrowser.jsSpeak("请张晓涵到.. **.. .. .. $$.. .. %%.. .. 第五诊室就诊");
        //AndroidBrowser.setWindowBrightness(10);
    }
    function callAndroid1() {
        str = AndroidBrowser.jsGetAndroidInfo("jsGetAndroidInfo");
        alert(str);
    }
    function callAndroid2() {
        volume = 5;
        type = 0;
        str = AndroidBrowser.jsSetAndroidVolume(volume, type);
        alert(str);
    }
    function clickTestSpeek() {
        str = document.getElementById("inputText").value;
        AndroidBrowser.setAndroidVolume(10)
        AndroidBrowser.setSpeechRate(1);
        AndroidBrowser.jsSpeak(str);
        //AndroidBrowser.setWindowBrightness(200);
        t = setInterval(function () {
            var isPlay = AndroidBrowser.ttsIsSpeak();
            if (!isPlay) {//播放完成
                clearInterval(t);
                alert("播放完成了");
            }
        }, 1500);
    }
    function ttsSpeakOver() {
        alert("ttsSpeakOver");
    }

    function updateApk() {
        var t = new Date().getTime();
        AndroidBrowser.downApk("http://192.168.0.10:8001/test.apk?tt=" + t);
    }
</script>

</html>